home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr54 / bison118.zip / BISON.INF < prev    next >
Text File  |  1993-06-01  |  38KB  |  922 lines

  1. Info file bison.info, produced by Makeinfo, -*- Text -*- from input
  2. file bison.texinfo.
  3.  
  4.    This file documents the Bison parser generator.
  5.  
  6.    Copyright (C) 1988, 1989, 1990 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this manual provided the copyright notice and this permission notice
  10. are preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and
  15. "Conditions for Using Bison" are included exactly as in the original,
  16. and provided that the entire resulting derived work is distributed
  17. under the terms of a permission notice identical to this one.
  18.  
  19.    Permission is granted to copy and distribute translations of this
  20. manual into another language, under the above conditions for modified
  21. versions, except that the sections entitled "GNU General Public
  22. License", "Conditions for Using Bison" and this permission notice may
  23. be included in translations approved by the Free Software Foundation
  24. instead of in the original English.
  25.  
  26. 
  27. File: bison.info,  Node: Semantic Tokens,  Next: Lexical Tie-ins,  Prev: Context Dependency,  Up: Context Dependency
  28.  
  29. Semantic Info in Token Types
  30. ============================
  31.  
  32.    The C language has a context dependency: the way an identifier is
  33. used depends on what its current meaning is.  For example, consider
  34. this:
  35.  
  36.      foo (x);
  37.  
  38.    This looks like a function call statement, but if `foo' is a typedef
  39. name, then this is actually a declaration of `x'.  How can a Bison
  40. parser for C decide how to parse this input?
  41.  
  42.    The method used in GNU C is to have two different token types,
  43. `IDENTIFIER' and `TYPENAME'.  When `yylex' finds an identifier, it
  44. looks up the current declaration of the identifier in order to decide
  45. which token type to return: `TYPENAME' if the identifier is declared
  46. as a typedef, `IDENTIFIER' otherwise.
  47.  
  48.    The grammar rules can then express the context dependency by the
  49. choice of token type to recognize.  `IDENTIFIER' is accepted as an
  50. expression, but `TYPENAME' is not.  `TYPENAME' can start a
  51. declaration, but `IDENTIFIER' cannot.  In contexts where the meaning
  52. of the identifier is *not* significant, such as in declarations that
  53. can shadow a typedef name, either `TYPENAME' or `IDENTIFIER' is
  54. accepted--there is one rule for each of the two token types.
  55.  
  56.    This technique is simple to use if the decision of which kinds of
  57. identifiers to allow is made at a place close to where the identifier
  58. is parsed.  But in C this is not always so: C allows a declaration to
  59. redeclare a typedef name provided an explicit type has been specified
  60. earlier:
  61.  
  62.      typedef int foo, bar, lose;
  63.      static foo (bar);        /* redeclare `bar' as static variable */
  64.      static int foo (lose);   /* redeclare `foo' as function */
  65.  
  66.    Unfortunately, the name being declared is separated from the
  67. declaration construct itself by a complicated syntactic structure--the
  68. "declarator".
  69.  
  70.    As a result, the part of Bison parser for C needs to be duplicated,
  71. with all the nonterminal names changed: once for parsing a declaration
  72. in which a typedef name can be redefined, and once for parsing a
  73. declaration in which that can't be done.  Here is a part of the
  74. duplication, with actions omitted for brevity:
  75.  
  76.      initdcl:
  77.                declarator maybeasm '='
  78.                init
  79.              | declarator maybeasm
  80.              ;
  81.      
  82.      notype_initdcl:
  83.                notype_declarator maybeasm '='
  84.                init
  85.              | notype_declarator maybeasm
  86.              ;
  87.  
  88. Here `initdcl' can redeclare a typedef name, but `notype_initdcl'
  89. cannot.  The distinction between `declarator' and `notype_declarator'
  90. is the same sort of thing.
  91.  
  92.    There is some similarity between this technique and a lexical tie-in
  93. (described next), in that information which alters the lexical
  94. analysis is changed during parsing by other parts of the program.  The
  95. difference is here the information is global, and is used for other
  96. purposes in the program.  A true lexical tie-in has a special-purpose
  97. flag controlled by the syntactic context.
  98.  
  99. 
  100. File: bison.info,  Node: Lexical Tie-ins,  Next: Tie-in Recovery,  Prev: Semantic Tokens,  Up: Context Dependency
  101.  
  102. Lexical Tie-ins
  103. ===============
  104.  
  105.    One way to handle context-dependency is the "lexical tie-in": a flag
  106. which is set by Bison actions, whose purpose is to alter the way
  107. tokens are parsed.
  108.  
  109.    For example, suppose we have a language vaguely like C, but with a
  110. special construct `hex (HEX-EXPR)'.  After the keyword `hex' comes an
  111. expression in parentheses in which all integers are hexadecimal.  In
  112. particular, the token `a1b' must be treated as an integer rather than
  113. as an identifier if it appears in that context.  Here is how you can
  114. do it:
  115.  
  116.      %{
  117.      int hexflag;
  118.      %}
  119.      %%
  120.      ...
  121.      expr:   IDENTIFIER
  122.              | constant
  123.              | HEX '('
  124.                      { hexflag = 1; }
  125.                expr ')'
  126.                      { hexflag = 0;
  127.                         $$ = $4; }
  128.              | expr '+' expr
  129.                      { $$ = make_sum ($1, $3); }
  130.              ...
  131.              ;
  132.      
  133.      constant:
  134.                INTEGER
  135.              | STRING
  136.              ;
  137.  
  138. Here we assume that `yylex' looks at the value of `hexflag'; when it
  139. is nonzero, all integers are parsed in hexadecimal, and tokens starting
  140. with letters are parsed as integers if possible.
  141.  
  142.    The declaration of `hexflag' shown in the C declarations section of
  143. the parser file is needed to make it accessible to the actions (*note
  144. C Declarations::.).  You must also write the code in `yylex' to obey
  145. the flag.
  146.  
  147. 
  148. File: bison.info,  Node: Tie-in Recovery,  Prev: Lexical Tie-ins,  Up: Context Dependency
  149.  
  150. Lexical Tie-ins and Error Recovery
  151. ==================================
  152.  
  153.    Lexical tie-ins make strict demands on any error recovery rules you
  154. have.  *Note Error Recovery::.
  155.  
  156.    The reason for this is that the purpose of an error recovery rule
  157. is to abort the parsing of one construct and resume in some larger
  158. construct.  For example, in C-like languages, a typical error recovery
  159. rule is to skip tokens until the next semicolon, and then start a new
  160. statement, like this:
  161.  
  162.      stmt:   expr ';'
  163.              | IF '(' expr ')' stmt { ... }
  164.              ...
  165.              error ';'
  166.                      { hexflag = 0; }
  167.              ;
  168.  
  169.    If there is a syntax error in the middle of a `hex (EXPR)'
  170. construct, this error rule will apply, and then the action for the
  171. completed `hex (EXPR)' will never run.  So `hexflag' would remain set
  172. for the entire rest of the input, or until the next `hex' keyword,
  173. causing identifiers to be misinterpreted as integers.
  174.  
  175.    To avoid this problem the error recovery rule itself clears
  176. `hexflag'.
  177.  
  178.    There may also be an error recovery rule that works within
  179. expressions.  For example, there could be a rule which applies within
  180. parentheses and skips to the close-parenthesis:
  181.  
  182.      expr:   ...
  183.              | '(' expr ')'
  184.                      { $$ = $2; }
  185.              | '(' error ')'
  186.              ...
  187.  
  188.    If this rule acts within the `hex' construct, it is not going to
  189. abort that construct (since it applies to an inner level of
  190. parentheses within the construct).  Therefore, it should not clear the
  191. flag: the rest of the `hex' construct should be parsed with the flag
  192. still in effect.
  193.  
  194.    What if there is an error recovery rule which might abort out of the
  195. `hex' construct or might not, depending on circumstances?  There is no
  196. way you can write the action to determine whether a `hex' construct is
  197. being aborted or not.  So if you are using a lexical tie-in, you had
  198. better make sure your error recovery rules are not of this kind.  Each
  199. rule must be such that you can be sure that it always will, or always
  200. won't, have to clear the flag.
  201.  
  202. 
  203. File: bison.info,  Node: Debugging,  Next: Invocation,  Prev: Context Dependency,  Up: Top
  204.  
  205. Debugging Your Parser
  206. *********************
  207.  
  208.    If a Bison grammar compiles properly but doesn't do what you want
  209. when it runs, the `yydebug' parser-trace feature can help you figure
  210. out why.
  211.  
  212.    To enable compilation of trace facilities, you must define the macro
  213. `YYDEBUG' when you compile the parser.  You could use `-DYYDEBUG=1' as
  214. a compiler option or you could put `#define YYDEBUG 1' in the C
  215. declarations section of the grammar file (*note C Declarations::.). 
  216. Alternatively, use the `-t' option when you run Bison (*note
  217. Invocation::.).  We always define `YYDEBUG' so that debugging is
  218. always possible.
  219.  
  220.    The trace facility uses `stderr', so you must add
  221. `#include <stdio.h>' to the C declarations section unless it is
  222. already there.
  223.  
  224.    Once you have compiled the program with trace facilities, the way to
  225. request a trace is to store a nonzero value in the variable `yydebug'. 
  226. You can do this by making the C code do it (in `main', perhaps), or
  227. you can alter the value with a C debugger.
  228.  
  229.    Each step taken by the parser when `yydebug' is nonzero produces a
  230. line or two of trace information, written on `stderr'.  The trace
  231. messages tell you these things:
  232.  
  233.    * Each time the parser calls `yylex', what kind of token was read.
  234.  
  235.    * Each time a token is shifted, the depth and complete contents of
  236.      the state stack (*note Parser States::.).
  237.  
  238.    * Each time a rule is reduced, which rule it is, and the complete
  239.      contents of the state stack afterward.
  240.  
  241.    To make sense of this information, it helps to refer to the listing
  242. file produced by the Bison `-v' option (*note Invocation::.).  This
  243. file shows the meaning of each state in terms of positions in various
  244. rules, and also what each state will do with each possible input
  245. token.  As you read the successive trace messages, you can see that
  246. the parser is functioning according to its specification in the
  247. listing file.  Eventually you will arrive at the place where something
  248. undesirable happens, and you will see which parts of the grammar are
  249. to blame.
  250.  
  251.    The parser file is a C program and you can use C debuggers on it,
  252. but it's not easy to interpret what it is doing.  The parser function
  253. is a finite-state machine interpreter, and aside from the actions it
  254. executes the same code over and over.  Only the values of variables
  255. show where in the grammar it is working.
  256.  
  257.    The debugging information normally gives the token type of each
  258. token read, but not its semantic value.  You can optionally define a
  259. macro named `YYPRINT' to provide a way to print the value.  If you
  260. define `YYPRINT', it should take three arguments.  The parser will
  261. pass a standard I/O stream, the numeric code for the token type, and
  262. the token value (from `yylval').
  263.  
  264.    Here is an example of `YYPRINT' suitable for the multi-function
  265. calculator (*note Mfcalc Decl::.):
  266.  
  267.      #define YYPRINT(file, type, value)   yyprint (file, type, value)
  268.      
  269.      static void
  270.      yyprint (file, type, value)
  271.           FILE *file;
  272.           int type;
  273.           YYSTYPE value;
  274.      {
  275.        if (type == VAR)
  276.          fprintf (file, " %s", value.tptr->name);
  277.        else if (type == NUM)
  278.          fprintf (file, " %d", value.val);
  279.      }
  280.  
  281. 
  282. File: bison.info,  Node: Invocation,  Next: Table of Symbols,  Prev: Debugging,  Up: Top
  283.  
  284. Invoking Bison
  285. **************
  286.  
  287.    The usual way to invoke Bison is as follows:
  288.  
  289.      bison INFILE
  290.  
  291.    Here INFILE is the grammar file name, which usually ends in `.y'. 
  292. The parser file's name is made by replacing the `.y' with `.tab.c'. 
  293. Thus, the `bison foo.y' filename yields `foo.tab.c', and the `bison
  294. hack/foo.y' filename yields `hack/foo.tab.c'.
  295.  
  296.    Bison supports both traditional single-letter options and mnemonic
  297. long option names.  Long option names are indicated with `--' instead
  298. of `-'.  Abbreviations for option names are allowed as long as they
  299. are unique.  When a long option takes an argument, like
  300. `--file-prefix', connect the option name and the argument with `='.
  301.  
  302.    Here is a list of options that can be used with Bison, alphabetized
  303. by short option.  It is followed by a cross key alphabetized by long
  304. option.
  305.  
  306. `-b FILE-PREFIX'
  307. `--file-prefix=PREFIX'
  308.      Specify a prefix to use for all Bison output file names.  The
  309.      names are chosen as if the input file were named `PREFIX.c'.
  310.  
  311. `-d'
  312. `--defines'
  313.      Write an extra output file containing macro definitions for the
  314.      token type names defined in the grammar and the semantic value
  315.      type `YYSTYPE', as well as a few `extern' variable declarations.
  316.  
  317.      If the parser output file is named `NAME.c' then this file is
  318.      named `NAME.h'.
  319.  
  320.      This output file is essential if you wish to put the definition of
  321.      `yylex' in a separate source file, because `yylex' needs to be
  322.      able to refer to token type codes and the variable `yylval'. 
  323.      *Note Token Values::.
  324.  
  325. `-l'
  326. `--no-lines'
  327.      Don't put any `#line' preprocessor commands in the parser file. 
  328.      Ordinarily Bison puts them in the parser file so that the C
  329.      compiler and debuggers will associate errors with your source
  330.      file, the grammar file.  This option causes them to associate
  331.      errors with the parser file, treating it an independent source
  332.      file in its own right.
  333.  
  334. `-o OUTFILE'
  335. `--output-file=OUTFILE'
  336.      Specify the name OUTFILE for the parser file.
  337.  
  338.      The other output files' names are constructed from OUTFILE as
  339.      described under the `-v' and `-d' switches.
  340.  
  341. `-p PREFIX'
  342. `--name-prefix=PREFIX'
  343.      Rename the external symbols used in the parser so that they start
  344.      with PREFIX instead of `yy'.  The precise list of symbols renamed
  345.      is `yyparse', `yylex', `yyerror', `yylval', `yychar' and
  346.      `yydebug'.
  347.  
  348.      For example, if you use `-p c', the names become `cparse',
  349.      `clex', and so on.
  350.  
  351.      *Note Multiple Parsers::.
  352.  
  353. `-t'
  354. `--debug'
  355.      Output a definition of the macro `YYDEBUG' into the parser file,
  356.      so that the debugging facilities are compiled.  *Note Debugging::.
  357.  
  358. `-v'
  359. `--verbose'
  360.      Write an extra output file containing verbose descriptions of the
  361.      parser states and what is done for each type of look-ahead token
  362.      in that state.
  363.  
  364.      This file also describes all the conflicts, both those resolved by
  365.      operator precedence and the unresolved ones.
  366.  
  367.      The file's name is made by removing `.tab.c' or `.c' from the
  368.      parser output file name, and adding `.output' instead.
  369.  
  370.      Therefore, if the input file is `foo.y', then the parser file is
  371.      called `foo.tab.c' by default.  As a consequence, the verbose
  372.      output file is called `foo.output'.
  373.  
  374. `-V'
  375. `--version'
  376.      Print the version number of Bison.
  377.  
  378. `-y'
  379. `--yacc'
  380. `--fixed-output-files'
  381.      Equivalent to `-o y.tab.c'; the parser output file is called
  382.      `y.tab.c', and the other outputs are called `y.output' and
  383.      `y.tab.h'.  The purpose of this switch is to imitate Yacc's output
  384.      file name conventions.  Thus, the following shell script can
  385.      substitute for Yacc:
  386.  
  387.           bison -y $*
  388.  
  389. Options' Cross Key
  390. ==================
  391.  
  392.    Here is a list of options, alphabetized by long option, to help you
  393. find the corresponding short option.
  394.  
  395.      --debug                               -t
  396.      --defines                             -d
  397.      --file-prefix=PREFIX                  -b FILE-PREFIX
  398.      --fixed-output-files --yacc           -y
  399.      --name-prefix                         -p
  400.      --no-lines                            -l
  401.      --output-file=OUTFILE                 -o OUTFILE
  402.      --verbose                             -v
  403.      --version                             -V
  404.  
  405. 
  406. File: bison.info,  Node: Table of Symbols,  Next: Glossary,  Prev: Invocation,  Up: Top
  407.  
  408. Bison Symbols
  409. *************
  410.  
  411. `error'
  412.      A token name reserved for error recovery.  This token may be used
  413.      in grammar rules so as to allow the Bison parser to recognize an
  414.      error in the grammar without halting the process.  In effect, a
  415.      sentence containing an error may be recognized as valid.  On a
  416.      parse error, the token `error' becomes the current look-ahead
  417.      token.  Actions corresponding to `error' are then executed, and
  418.      the look-ahead token is reset to the token that originally caused
  419.      the violation.  *Note Error Recovery::.
  420.  
  421. `YYABORT'
  422.      Macro to pretend that an unrecoverable syntax error has occurred,
  423.      by making `yyparse' return 1 immediately.  The error reporting
  424.      function `yyerror' is not called.  *Note Parser Function::.
  425.  
  426. `YYACCEPT'
  427.      Macro to pretend that a complete utterance of the language has
  428.      been read, by making `yyparse' return 0 immediately.  *Note
  429.      Parser Function::.
  430.  
  431. `YYBACKUP'
  432.      Macro to discard a value from the parser stack and fake a
  433.      look-ahead token.  *Note Action Features::.
  434.  
  435. `YYERROR'
  436.      Macro to pretend that a syntax error has just been detected: call
  437.      `yyerror' and then perform normal error recovery if possible
  438.      (*note Error Recovery::.), or (if recovery is impossible) make
  439.      `yyparse' return 1.  *Note Error Recovery::.
  440.  
  441. `YYINITDEPTH'
  442.      Macro for specifying the initial size of the parser stack.  *Note
  443.      Stack Overflow::.
  444.  
  445. `YYLTYPE'
  446.      Macro for the data type of `yylloc'; a structure with four
  447.      members.  *Note Token Positions::.
  448.  
  449. `YYMAXDEPTH'
  450.      Macro for specifying the maximum size of the parser stack.  *Note
  451.      Stack Overflow::.
  452.  
  453. `YYRECOVERING'
  454.      Macro whose value indicates whether the parser is recovering from
  455.      a syntax error.  *Note Action Features::.
  456.  
  457. `YYSTYPE'
  458.      Macro for the data type of semantic values; `int' by default. 
  459.      *Note Value Type::.
  460.  
  461. `yychar'
  462.      External integer variable that contains the integer value of the
  463.      current look-ahead token.  (In a pure parser, it is a local
  464.      variable within `yyparse'.)  Error-recovery rule actions may
  465.      examine this variable.  *Note Action Features::.
  466.  
  467. `yyclearin'
  468.      Macro used in error-recovery rule actions.  It clears the previous
  469.      look-ahead token.  *Note Error Recovery::.
  470.  
  471. `yydebug'
  472.      External integer variable set to zero by default.  If `yydebug'
  473.      is given a nonzero value, the parser will output information on
  474.      input symbols and parser action.  *Note Debugging::.
  475.  
  476. `yyerrok'
  477.      Macro to cause parser to recover immediately to its normal mode
  478.      after a parse error.  *Note Error Recovery::.
  479.  
  480. `yyerror'
  481.      User-supplied function to be called by `yyparse' on error.  The
  482.      function receives one argument, a pointer to a character string
  483.      containing an error message.  *Note Error Reporting::.
  484.  
  485. `yylex'
  486.      User-supplied lexical analyzer function, called with no arguments
  487.      to get the next token.  *Note Lexical::.
  488.  
  489. `yylval'
  490.      External variable in which `yylex' should place the semantic
  491.      value associated with a token.  (In a pure parser, it is a local
  492.      variable within `yyparse', and its address is passed to `yylex'.)
  493.       *Note Token Values::.
  494.  
  495. `yylloc'
  496.      External variable in which `yylex' should place the line and
  497.      column numbers associated with a token.  (In a pure parser, it is
  498.      a local variable within `yyparse', and its address is passed to
  499.      `yylex'.)  You can ignore this variable if you don't use the `@'
  500.      feature in the grammar actions.  *Note Token Positions::.
  501.  
  502. `yynerrs'
  503.      Global variable which Bison increments each time there is a parse
  504.      error.  (In a pure parser, it is a local variable within
  505.      `yyparse'.)  *Note Error Reporting::.
  506.  
  507. `yyparse'
  508.      The parser function produced by Bison; call this function to start
  509.      parsing.  *Note Parser Function::.
  510.  
  511. `%left'
  512.      Bison declaration to assign left associativity to token(s). 
  513.      *Note Precedence Decl::.
  514.  
  515. `%nonassoc'
  516.      Bison declaration to assign nonassociativity to token(s).  *Note
  517.      Precedence Decl::.
  518.  
  519. `%prec'
  520.      Bison declaration to assign a precedence to a specific rule. 
  521.      *Note Contextual Precedence::.
  522.  
  523. `%pure_parser'
  524.      Bison declaration to request a pure (reentrant) parser.  *Note
  525.      Pure Decl::.
  526.  
  527. `%right'
  528.      Bison declaration to assign right associativity to token(s). 
  529.      *Note Precedence Decl::.
  530.  
  531. `%start'
  532.      Bison declaration to specify the start symbol.  *Note Start
  533.      Decl::.
  534.  
  535. `%token'
  536.      Bison declaration to declare token(s) without specifying
  537.      precedence.  *Note Token Decl::.
  538.  
  539. `%type'
  540.      Bison declaration to declare nonterminals.  *Note Type Decl::.
  541.  
  542. `%union'
  543.      Bison declaration to specify several possible data types for
  544.      semantic values.  *Note Union Decl::.
  545.  
  546.    These are the punctuation and delimiters used in Bison input:
  547.  
  548. `%%'
  549.      Delimiter used to separate the grammar rule section from the
  550.      Bison declarations section or the additional C code section. 
  551.      *Note Grammar Layout::.
  552.  
  553. `%{ %}'
  554.      All code listed between `%{' and `%}' is copied directly to the
  555.      output file uninterpreted.  Such code forms the "C declarations"
  556.      section of the input file.  *Note Grammar Outline::.
  557.  
  558. `/*...*/'
  559.      Comment delimiters, as in C.
  560.  
  561. `:'
  562.      Separates a rule's result from its components.  *Note Rules::.
  563.  
  564. `;'
  565.      Terminates a rule.  *Note Rules::.
  566.  
  567. `|'
  568.      Separates alternate rules for the same result nonterminal.  *Note
  569.      Rules::.
  570.  
  571. 
  572. File: bison.info,  Node: Glossary,  Next: Index,  Prev: Table of Symbols,  Up: top
  573.  
  574. Glossary
  575. ********
  576.  
  577. Backus-Naur Form (BNF)
  578.      Formal method of specifying context-free grammars.  BNF was first
  579.      used in the `ALGOL-60' report, 1963.  *Note Language and
  580.      Grammar::.
  581.  
  582. Context-free grammars
  583.      Grammars specified as rules that can be applied regardless of
  584.      context.  Thus, if there is a rule which says that an integer can
  585.      be used as an expression, integers are allowed *anywhere* an
  586.      expression is permitted.  *Note Language and Grammar::.
  587.  
  588. Dynamic allocation
  589.      Allocation of memory that occurs during execution, rather than at
  590.      compile time or on entry to a function.
  591.  
  592. Empty string
  593.      Analogous to the empty set in set theory, the empty string is a
  594.      character string of length zero.
  595.  
  596. Finite-state stack machine
  597.      A "machine" that has discrete states in which it is said to exist
  598.      at each instant in time.  As input to the machine is processed,
  599.      the machine moves from state to state as specified by the logic
  600.      of the machine.  In the case of the parser, the input is the
  601.      language being parsed, and the states correspond to various
  602.      stages in the grammar rules.  *Note Algorithm::.
  603.  
  604. Grouping
  605.      A language construct that is (in general) grammatically divisible;
  606.      for example, `expression' or `declaration' in C.  *Note Language
  607.      and Grammar::.
  608.  
  609. Infix operator
  610.      An arithmetic operator that is placed between the operands on
  611.      which it performs some operation.
  612.  
  613. Input stream
  614.      A continuous flow of data between devices or programs.
  615.  
  616. Language construct
  617.      One of the typical usage schemas of the language.  For example,
  618.      one of the constructs of the C language is the `if' statement. 
  619.      *Note Language and Grammar::.
  620.  
  621. Left associativity
  622.      Operators having left associativity are analyzed from left to
  623.      right: `a+b+c' first computes `a+b' and then combines with `c'. 
  624.      *Note Precedence::.
  625.  
  626. Left recursion
  627.      A rule whose result symbol is also its first component symbol;
  628.      for example, `expseq1 : expseq1 ',' exp;'.  *Note Recursion::.
  629.  
  630. Left-to-right parsing
  631.      Parsing a sentence of a language by analyzing it token by token
  632.      from left to right.  *Note Algorithm::.
  633.  
  634. Lexical analyzer (scanner)
  635.      A function that reads an input stream and returns tokens one by
  636.      one.  *Note Lexical::.
  637.  
  638. Lexical tie-in
  639.      A flag, set by actions in the grammar rules, which alters the way
  640.      tokens are parsed.  *Note Lexical Tie-ins::.
  641.  
  642. Look-ahead token
  643.      A token already read but not yet shifted.  *Note Look-Ahead::.
  644.  
  645. LALR(1)
  646.      The class of context-free grammars that Bison (like most other
  647.      parser generators) can handle; a subset of LR(1).  *Note 
  648.      Mysterious Reduce/Reduce Conflicts: Mystery Conflicts.
  649.  
  650. LR(1)
  651.      The class of context-free grammars in which at most one token of
  652.      look-ahead is needed to disambiguate the parsing of any piece of
  653.      input.
  654.  
  655. Nonterminal symbol
  656.      A grammar symbol standing for a grammatical construct that can be
  657.      expressed through rules in terms of smaller constructs; in other
  658.      words, a construct that is not a token.  *Note Symbols::.
  659.  
  660. Parse error
  661.      An error encountered during parsing of an input stream due to
  662.      invalid syntax.  *Note Error Recovery::.
  663.  
  664. Parser
  665.      A function that recognizes valid sentences of a language by
  666.      analyzing the syntax structure of a set of tokens passed to it
  667.      from a lexical analyzer.
  668.  
  669. Postfix operator
  670.      An arithmetic operator that is placed after the operands upon
  671.      which it performs some operation.
  672.  
  673. Reduction
  674.      Replacing a string of nonterminals and/or terminals with a single
  675.      nonterminal, according to a grammar rule.  *Note Algorithm::.
  676.  
  677. Reentrant
  678.      A reentrant subprogram is a subprogram which can be in invoked any
  679.      number of times in parallel, without interference between the
  680.      various invocations.  *Note Pure Decl::.
  681.  
  682. Reverse polish notation
  683.      A language in which all operators are postfix operators.
  684.  
  685. Right recursion
  686.      A rule whose result symbol is also its last component symbol; for
  687.      example, `expseq1: exp ',' expseq1;'.  *Note Recursion::.
  688.  
  689. Semantics
  690.      In computer languages, the semantics are specified by the actions
  691.      taken for each instance of the language, i.e., the meaning of
  692.      each statement.  *Note Semantics::.
  693.  
  694. Shift
  695.      A parser is said to shift when it makes the choice of analyzing
  696.      further input from the stream rather than reducing immediately
  697.      some already-recognized rule.  *Note Algorithm::.
  698.  
  699. Single-character literal
  700.      A single character that is recognized and interpreted as is. 
  701.      *Note Grammar in Bison::.
  702.  
  703. Start symbol
  704.      The nonterminal symbol that stands for a complete valid utterance
  705.      in the language being parsed.  The start symbol is usually listed
  706.      as the first nonterminal symbol in a language specification. 
  707.      *Note Start Decl::.
  708.  
  709. Symbol table
  710.      A data structure where symbol names and associated data are stored
  711.      during parsing to allow for recognition and use of existing
  712.      information in repeated uses of a symbol.  *Note Multi-function
  713.      Calc::.
  714.  
  715. Token
  716.      A basic, grammatically indivisible unit of a language.  The symbol
  717.      that describes a token in the grammar is a terminal symbol.  The
  718.      input of the Bison parser is a stream of tokens which comes from
  719.      the lexical analyzer.  *Note Symbols::.
  720.  
  721. Terminal symbol
  722.      A grammar symbol that has no rules in the grammar and therefore
  723.      is grammatically indivisible.  The piece of text it represents is
  724.      a token.  *Note Language and Grammar::.
  725.  
  726. 
  727. File: bison.info,  Node: Index,  Prev: Glossary,  Up: top
  728.  
  729. Index
  730. *****
  731.  
  732. * Menu:
  733.  
  734. * $$:                                   Actions.
  735. * $N:                                   Actions.
  736. * %expect:                              Expect Decl.
  737. * %left:                                Using Precedence.
  738. * %nonassoc:                            Using Precedence.
  739. * %prec:                                Contextual Precedence.
  740. * %pure_parser:                         Pure Decl.
  741. * %right:                               Using Precedence.
  742. * %start:                               Start Decl.
  743. * %token:                               Token Decl.
  744. * %type:                                Type Decl.
  745. * %union:                               Union Decl.
  746. * @N:                                   Action Features.
  747. * calc:                                 Infix Calc.
  748. * else, dangling:                       Shift/Reduce.
  749. * mfcalc:                               Multi-function Calc.
  750. * rpcalc:                               RPN Calc.
  751. * BNF:                                  Language and Grammar.
  752. * Backus-Naur form:                     Language and Grammar.
  753. * Bison declaration summary:            Decl Summary.
  754. * Bison declarations:                   Declarations.
  755. * Bison declarations (introduction):    Bison Declarations.
  756. * Bison grammar:                        Grammar in Bison.
  757. * Bison invocation:                     Invocation.
  758. * Bison parser:                         Bison Parser.
  759. * Bison parser algorithm:               Algorithm.
  760. * Bison symbols, table of:              Table of Symbols.
  761. * Bison utility:                        Bison Parser.
  762. * C code, section for additional:       C Code.
  763. * C declarations section:               C Declarations.
  764. * C-language interface:                 Interface.
  765. * LALR(1):                              Mystery Conflicts.
  766. * LR(1):                                Mystery Conflicts.
  767. * YYABORT:                              Parser Function.
  768. * YYACCEPT:                             Parser Function.
  769. * YYBACKUP:                             Action Features.
  770. * YYDEBUG:                              Debugging.
  771. * YYEMPTY:                              Action Features.
  772. * YYERROR:                              Action Features.
  773. * YYINITDEPTH:                          Stack Overflow.
  774. * YYLTYPE:                              Token Positions.
  775. * YYMAXDEPTH:                           Stack Overflow.
  776. * YYPRINT:                              Debugging.
  777. * YYRECOVERING:                         Error Recovery.
  778. * action:                               Actions.
  779. * action data types:                    Action Types.
  780. * action features summary:              Action Features.
  781. * actions in mid-rule:                  Mid-Rule Actions.
  782. * actions, semantic:                    Semantic Actions.
  783. * additional C code section:            C Code.
  784. * algorithm of parser:                  Algorithm.
  785. * associativity:                        Why Precedence.
  786. * calculator, infix notation:           Infix Calc.
  787. * calculator, multi-function:           Multi-function Calc.
  788. * calculator, simple:                   RPN Calc.
  789. * character token:                      Symbols.
  790. * compiling the parser:                 Rpcalc Compile.
  791. * conflicts:                            Shift/Reduce.
  792. * conflicts, reduce/reduce:             Reduce/Reduce.
  793. * conflicts, suppressing warnings of:   Expect Decl.
  794. * context-dependent precedence:         Contextual Precedence.
  795. * context-free grammar:                 Language and Grammar.
  796. * controlling function:                 Rpcalc Main.
  797. * dangling else:                        Shift/Reduce.
  798. * data types in actions:                Action Types.
  799. * data types of semantic values:        Value Type.
  800. * debugging:                            Debugging.
  801. * declaration summary:                  Decl Summary.
  802. * declarations, Bison:                  Declarations.
  803. * declarations, Bison (introduction):   Bison Declarations.
  804. * declarations, C:                      C Declarations.
  805. * declaring operator precedence:        Precedence Decl.
  806. * declaring the start symbol:           Start Decl.
  807. * declaring token type names:           Token Decl.
  808. * declaring value types:                Union Decl.
  809. * declaring value types, nonterminals:  Type Decl.
  810. * defining language semantics:          Semantics.
  811. * error:                                Error Recovery.
  812. * error recovery:                       Error Recovery.
  813. * error recovery, simple:               Simple Error Recovery.
  814. * error reporting function:             Error Reporting.
  815. * error reporting routine:              Rpcalc Error.
  816. * examples, simple:                     Examples.
  817. * exercises:                            Exercises.
  818. * file format:                          Grammar Layout.
  819. * finite-state machine:                 Parser States.
  820. * formal grammar:                       Grammar in Bison.
  821. * format of grammar file:               Grammar Layout.
  822. * glossary:                             Glossary.
  823. * grammar file:                         Grammar Layout.
  824. * grammar rule syntax:                  Rules.
  825. * grammar rules section:                Grammar Rules.
  826. * grammar, Bison:                       Grammar in Bison.
  827. * grammar, context-free:                Language and Grammar.
  828. * grouping, syntactic:                  Language and Grammar.
  829. * infix notation calculator:            Infix Calc.
  830. * interface:                            Interface.
  831. * introduction:                         Introduction.
  832. * invoking Bison:                       Invocation.
  833. * language semantics, defining:         Semantics.
  834. * layout of Bison grammar:              Grammar Layout.
  835. * left recursion:                       Recursion.
  836. * lexical analyzer:                     Lexical.
  837. * lexical analyzer, purpose:            Bison Parser.
  838. * lexical analyzer, writing:            Rpcalc Lexer.
  839. * lexical tie-in:                       Lexical Tie-ins.
  840. * literal token:                        Symbols.
  841. * look-ahead token:                     Look-Ahead.
  842. * main function in simple example:      Rpcalc Main.
  843. * mid-rule actions:                     Mid-Rule Actions.
  844. * multi-function calculator:            Multi-function Calc.
  845. * mutual recursion:                     Recursion.
  846. * nonterminal symbol:                   Symbols.
  847. * operator precedence:                  Precedence.
  848. * operator precedence, declaring:       Precedence Decl.
  849. * options for invoking Bison:           Invocation.
  850. * overflow of parser stack:             Stack Overflow.
  851. * parse error:                          Error Reporting.
  852. * parser:                               Bison Parser.
  853. * parser stack:                         Algorithm.
  854. * parser stack overflow:                Stack Overflow.
  855. * parser state:                         Parser States.
  856. * polish notation calculator:           RPN Calc.
  857. * precedence declarations:              Precedence Decl.
  858. * precedence of operators:              Precedence.
  859. * precedence, context-dependent:        Contextual Precedence.
  860. * precedence, unary operator:           Contextual Precedence.
  861. * preventing warnings about conflicts:  Expect Decl.
  862. * pure parser:                          Pure Decl.
  863. * recovery from errors:                 Error Recovery.
  864. * recursive rule:                       Recursion.
  865. * reduce/reduce conflict:               Reduce/Reduce.
  866. * reduction:                            Algorithm.
  867. * reentrant parser:                     Pure Decl.
  868. * reverse polish notation:              RPN Calc.
  869. * right recursion:                      Recursion.
  870. * rule syntax:                          Rules.
  871. * rules section for grammar:            Grammar Rules.
  872. * running Bison (introduction):         Rpcalc Gen.
  873. * semantic actions:                     Semantic Actions.
  874. * semantic value:                       Semantic Values.
  875. * semantic value type:                  Value Type.
  876. * shift/reduce conflicts:               Shift/Reduce.
  877. * shifting:                             Algorithm.
  878. * simple examples:                      Examples.
  879. * single-character literal:             Symbols.
  880. * stack overflow:                       Stack Overflow.
  881. * stack, parser:                        Algorithm.
  882. * stages in using Bison:                Stages.
  883. * start symbol:                         Language and Grammar.
  884. * start symbol, declaring:              Start Decl.
  885. * state (of parser):                    Parser States.
  886. * summary, Bison declaration:           Decl Summary.
  887. * summary, action features:             Action Features.
  888. * suppressing conflict warnings:        Expect Decl.
  889. * symbol:                               Symbols.
  890. * symbol table example:                 Mfcalc Symtab.
  891. * symbols (abstract):                   Language and Grammar.
  892. * symbols in Bison, table of:           Table of Symbols.
  893. * syntactic grouping:                   Language and Grammar.
  894. * syntax error:                         Error Reporting.
  895. * syntax of grammar rules:              Rules.
  896. * terminal symbol:                      Symbols.
  897. * token:                                Language and Grammar.
  898. * token type:                           Symbols.
  899. * token type names, declaring:          Token Decl.
  900. * tracing the parser:                   Debugging.
  901. * unary operator precedence:            Contextual Precedence.
  902. * using Bison:                          Stages.
  903. * value type, semantic:                 Value Type.
  904. * value types, declaring:               Union Decl.
  905. * value types, nonterminals, declaring: Type Decl.
  906. * value, semantic:                      Semantic Values.
  907. * warnings, preventing:                 Expect Decl.
  908. * writing a lexical analyzer:           Rpcalc Lexer.
  909. * yychar:                               Look-Ahead.
  910. * yyclearin:                            Error Recovery.
  911. * yydebug:                              Debugging.
  912. * yyerrok:                              Error Recovery.
  913. * yyerror:                              Error Reporting.
  914. * yylex:                                Lexical.
  915. * yylloc:                               Token Positions.
  916. * yylval:                               Token Values.
  917. * yynerrs:                              Error Reporting.
  918. * yyparse:                              Parser Function.
  919. * |:                                    Rules.
  920.  
  921.  
  922.